package com.ych.proxy;

/**
 * @author yangchenghao
 */
public class CalculatorProxy implements Calculator {
    private Calculator target;

    public CalculatorProxy(Calculator target) {
        this.target = target;
    }

    @Override
    public int add(int i, int j) {
        System.out.println("日志：方法add，参数：" + i + "," + j);
        int result = target.add(i, j);
        System.out.println("日志：方法add，结果：" + result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("日志：方法sub，参数：" + i + "," + j);
        int result = target.sub(i, j);
        System.out.println("日志：方法sub，结果：" + result);
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("日志：方法mul，参数：" + i + "," + j);
        int result = target.mul(i, j);
        System.out.println("日志：方法mul，结果：" + result);
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("日志：方法div，参数：" + i + "," + j);
        int result = target.div(i, j);
        System.out.println("日志：方法div，结果：" + result);
        return result;
    }
}
